/*     */ package com.zimbra.cs.mailbox;
/*     */ 
/*     */ import com.google.common.annotations.VisibleForTesting;
/*     */ import com.zimbra.common.localconfig.DebugConfig;
/*     */ import com.zimbra.cs.account.Account;
/*     */ import com.zimbra.cs.datasource.DataSourceListener;
/*     */ import com.zimbra.cs.fb.FreeBusyProvider.Listener;
/*     */ import com.zimbra.cs.filter.FilterListener;
/*     */ import com.zimbra.cs.mailbox.acl.AclPushListener;
/*     */ import com.zimbra.cs.mailbox.acl.ShareExpirationListener;
/*     */ import com.zimbra.cs.mailbox.alerts.CalItemReminderService;
/*     */ import com.zimbra.cs.session.PendingModifications;
/*     */ import com.zimbra.cs.util.ZimbraApplication;
/*     */ import java.util.Collections;
/*     */ import java.util.EnumSet;
/*     */ import java.util.HashSet;
/*     */ import java.util.Set;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public abstract class MailboxListener
/*     */ {
/*     */   public static class ChangeNotification
/*     */   {
/*     */     public Account mailboxAccount;
/*     */     public OperationContext ctxt;
/*     */     public int lastChangeId;
/*     */     public PendingModifications mods;
/*     */     public MailboxOperation op;
/*     */     public long timestamp;
/*     */     
/*     */     public ChangeNotification(Account account, PendingModifications mods, OperationContext ctxt, int lastChangeId, MailboxOperation op, long timestamp)
/*     */     {
/*  50 */       this.mailboxAccount = account;
/*  51 */       this.mods = mods;
/*  52 */       this.ctxt = ctxt;
/*  53 */       this.lastChangeId = lastChangeId;
/*  54 */       this.op = op;
/*  55 */       this.timestamp = timestamp;
/*     */     }
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*  69 */   protected static final Set<MailItem.Type> ALL_ITEM_TYPES = EnumSet.allOf(MailItem.Type.class);
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public Set<MailItem.Type> registerForItemTypes()
/*     */   {
/*  78 */     return ALL_ITEM_TYPES;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*  84 */   private static final HashSet<MailboxListener> sListeners = new HashSet();
/*  85 */   static { reset(); }
/*     */   
/*     */   static void reset()
/*     */   {
/*  89 */     sListeners.clear();
/*  90 */     ZimbraApplication application = ZimbraApplication.getInstance();
/*  91 */     if ((application.supports(CalItemReminderService.class)) && (!DebugConfig.disableCalendarReminderEmail)) {
/*  92 */       register(new CalItemReminderService());
/*     */     }
/*  94 */     register(new FilterListener());
/*  95 */     register(new MemcachedCacheManager());
/*  96 */     register(new FreeBusyProvider.Listener());
/*  97 */     register(new DataSourceListener());
/*  98 */     register(new ShareStartStopListener());
/*  99 */     if (application.supports(AclPushListener.class)) {
/* 100 */       register(new AclPushListener());
/*     */     }
/* 102 */     if ((application.supports(ShareExpirationListener.class)) && (!DebugConfig.disableShareExpirationListener)) {
/* 103 */       register(new ShareExpirationListener());
/*     */     }
/*     */   }
/*     */   
/*     */   public static void register(MailboxListener listener) {
/* 108 */     synchronized (sListeners) {
/* 109 */       sListeners.add(listener);
/*     */     }
/*     */   }
/*     */   
/*     */   @VisibleForTesting
/*     */   static void unregister(MailboxListener listener) {
/* 115 */     synchronized (sListeners) {
/* 116 */       sListeners.remove(listener);
/*     */     }
/*     */   }
/*     */   
/*     */   public static void notifyListeners(ChangeNotification notification) {
/* 121 */     for (MailboxListener l : sListeners) {
/* 122 */       if (!Collections.disjoint(notification.mods.changedTypes, l.registerForItemTypes())) {
/* 123 */         l.notify(notification);
/*     */       }
/*     */     }
/*     */   }
/*     */   
/*     */   public abstract void notify(ChangeNotification paramChangeNotification);
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/mailbox/MailboxListener.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */